/////////////////////////////////////////////////////////////////////////////
// Name:        wxmudauinotebook.cpp
// Purpose:     
// Author:      Stephen Whittle
// Modified by: 
// Created:     06/07/2009 18:47:09
// RCS-ID:      
// Copyright:   
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
#include "wx/imaglist.h"
#include "wxmudtextctrl.h"
////@end includes

#include "wxmudauinotebook.h"
#include "globals.h"
////@begin XPM images
////@end XPM images


/*
 * wxMudAuiNotebook type definition
 */

IMPLEMENT_DYNAMIC_CLASS( wxMudAuiNotebook, wxAuiNotebook )


/*
 * wxMudAuiNotebook event table definition
 */

BEGIN_EVENT_TABLE( wxMudAuiNotebook, wxAuiNotebook )

////@begin wxMudAuiNotebook event table entries
////@end wxMudAuiNotebook event table entries
    EVT_AUINOTEBOOK_TAB_RIGHT_UP( wxID_ANY, wxMudAuiNotebook::OnTabRightClick )
    EVT_MENU(wxID_RENAME, wxMudAuiNotebook::OnRenameTabEvent)
END_EVENT_TABLE()


/*
 * wxMudAuiNotebook constructors
 */

wxMudAuiNotebook::wxMudAuiNotebook()
{
    Init();
}

wxMudAuiNotebook::wxMudAuiNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
    Init();
    Create(parent, id, pos, size, style);
}


/*
 * wxMudAuiNotebook creator
 */

bool wxMudAuiNotebook::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin wxMudAuiNotebook creation
    wxAuiNotebook::Create(parent, id, pos, size, style);
    CreateControls();
////@end wxMudAuiNotebook creation
    return true;
}


/*
 * wxMudAuiNotebook destructor
 */

wxMudAuiNotebook::~wxMudAuiNotebook()
{
////@begin wxMudAuiNotebook destruction
////@end wxMudAuiNotebook destruction
}


/*
 * Member initialisation
 */

void wxMudAuiNotebook::Init()
{
////@begin wxMudAuiNotebook member initialisation
    m_Pane1 = NULL;
////@end wxMudAuiNotebook member initialisation
}


/*
 * Control creation for wxMudAuiNotebook
 */

void wxMudAuiNotebook::CreateControls()
{    
////@begin wxMudAuiNotebook content construction
    wxMudAuiNotebook* itemAuiNotebook1 = this;

    this->SetForegroundColour(wxColour(255, 255, 255));
    m_Pane1 = new wxMudTextCtrl( itemAuiNotebook1, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    m_Pane1->SetForegroundColour(wxColour(255, 255, 255));
    m_Pane1->SetBackgroundColour(wxColour(0, 0, 0));

    this->AddPage(m_Pane1, _("Tab"), false);

////@end wxMudAuiNotebook content construction
mudTextWindows.Add(m_Pane1);
}


/*
 * Should we show tooltips?
 */

bool wxMudAuiNotebook::ShowToolTips()
{
    return true;
}

/*
 * Get bitmap resources
 */

wxBitmap wxMudAuiNotebook::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin wxMudAuiNotebook bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end wxMudAuiNotebook bitmap retrieval
}

/*
 * Get icon resources
 */

wxIcon wxMudAuiNotebook::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin wxMudAuiNotebook icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end wxMudAuiNotebook icon retrieval
}

void wxMudAuiNotebook::OnTabRightClick( wxAuiNotebookEvent& event )
{
currentSelection = event.GetSelection();
wxMenu * tabRClickMenu = new wxMenu(wxT("Tab Options"));
tabRClickMenu->Append(wxID_RENAME,wxT("Rename Tab"));
PopupMenu(tabRClickMenu);
}

void wxMudAuiNotebook::OnRenameTabEvent (wxCommandEvent & event){
    wxString newName = wxGetTextFromUser(wxEmptyString, wxT("Enter a new name for the tab:"));
        if (newName == wxEmptyString){
    return;
    }
    this->SetPageText(currentSelection, newName);
    //currentSelection->windowName = newName;
    //get the manager for the windoq
    //get the pane using the tab pointer and the manager
    //use paneinfo reference to set the name
    ((wxMudTextCtrl*)(this->GetPage(currentSelection)))->windowName = newName;
    this->SetPageText(currentSelection,newName);
}


/*
 * wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP event handler for ID_AUINOTEBOOK1
 */


